package com.cyh.web.schedule;

import com.cyh.core.framework.common.utils.TimeUtil;
import com.cyh.core.framework.common.constant.TimeConstant;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author: yanhang_chen
 * @Date: 2020/9/8 15:57
 */
@Component
public class ScheduledTask {

    //项目启动后等待 initialDelay 再执行，每次执行完等待fixedDelay
    @Scheduled( initialDelay = 20 * TimeConstant.SECOND , fixedDelay = 5 * TimeConstant.MINUTE )
    public void scheduledTask() {
        System.out.println(TimeUtil.getNow()+
                " 定时任务执行了 "+this.getClass().getName()+
                "."+Thread.currentThread().getStackTrace()[1].getMethodName()+"()");
    }
}
